/**
 * 医疗服务质询初始化模块，提供医疗服务编辑页面初始化组件功能
 * 
 * @Date: 2016-1-25
 * @author: Jackson wang
 * @version: 1.0
 * @since: 1.0
 */

define(["jquery","sysmanMain","dateUtil"],
		function($,sysmanMain,dateUtil) {
			
		'use strict';
		
		var public_method ={
			
			/**
			 * 获取高级查询字段内容
			 * @param _options.rootId
			 */
			getConditionValue:function(_options){
				var _rootpath = '/'+sysmanMain.getRootPath()
				var ret = {}
				if(_options.rootId && _options.form){
					var $form = $('#' + _options.rootId + ' ' + _options.form)
					if($form.length>0){
						var boxElement=['doct_depart_name','doct_name','inpatient_no']
						for(var i=0;i<boxElement.length;i++){
							var _tmpValue = private_method.getTextboxValue($form,boxElement[i])
							if(_tmpValue){
								ret = $.extend(ret,_tmpValue)
							}
						}
					}
					
					var $condition = $('#' + _options.rootId + ' ' +" div.tb-list")
					if($condition.length>0){
							
						var _timeValue=	dateUtil.getStartEndDate({
								fieldName:'inhzospitalat',
								startEl:$condition.find('#inhzospitalat_start'),
								endEl:$condition.find('#inhzospitalat_end')
							})
						if(_timeValue!=null && !$.isEmptyObject(_timeValue)){
							ret=$.extend(ret,_timeValue)
						}
					}
				}
				return ret
			},
			
			
			/**
			 * 设置模块点击页面
			 * @param _options.record 列表选中行
			 * @param _options.grid 页面form对象
			 * @param _options.rootId 页面根节点
			 */
			clickCell:function(index,field,value){
				
				var _config = sysmanMain.getCurrentModuConfig()
				
				if(!value  || value<=0){
					_config.clickValue = 0
					sysmanMain.setCurrentModuConfig(_config)
					return 
				}else{
					_config.clickValue = 1
					sysmanMain.setCurrentModuConfig(_config)
				}
				var _param ={}
				if(field && (field!=='inquiry_count')){
					_param.issue = field
				}				
				
				_config.clickParam = _param				
				sysmanMain.setCurrentModuConfig(_config)
				
			},
			
			/**
			 * 设置模块点击参数页面
			 * @param _options.record 列表选中行
			 * @param _options.grid 页面form对象
			 * @param _options.rootId 页面根节点
			 */
			clickRow:function(index,row){
				if(window.console){
					console.log('index:' + index)
					console.log('row.litigant_deptname:' + row.litigant_deptname)					
				}
				var _config = sysmanMain.getCurrentModuConfig()	
				
				//点击为0cell
				if(_config.clickValue <= 0){
					return 
				}
				var _param = {litigant_deptid:row.litigant_deptid}
				if (_config.clickParam){					
					$.extend(_config.clickParam,_param) 
				}else{
					_config.clickParam = _param
				}
				sysmanMain.setCurrentModuConfig(_config)
				
				var initQueryParams = {condition:_config.clickParam}
				
				
				sysmanMain.setModuConf('dutiesInquiryInfo',{initQueryParams:initQueryParams})
				
				sysmanMain.dutiesInquiryInfoSelect()
			}	
		}			
		
		return public_method;
			
})